<template>
  <div>
    <el-cascader
      v-model="bloc.value"
      :options="bloc.options"
      :placeholder="'请选择'"
      style="width:100%;"
      :props="{multiple:true}"
      @change="handleChange">
    </el-cascader>
  </div>
</template>

<script lang='ts'>
    // import { getLabelList } from './api.js'
    import { Component, Prop, Vue } from 'vue-property-decorator';
    import {ProctutModelBloc} from '@/component/bloc/ProctutModelBloc';

    @Component
    export default class UserSelector extends Vue {
        @Prop({ type: String })
        readonly targetProducts! : string;

        bloc = new ProctutModelBloc();
        async created () {
            // 生成供选择数据
            await this.bloc.load();
            let address = this.bloc.normalizedOptions;
            address.forEach(item => {
                this.bloc.options.push(item)
            });
            // 获取已选择的数据
            if (this.targetProducts) {
                this.bloc.value = JSON.parse(this.targetProducts);
            }
        }

        handleChange(value) {
            this.$emit('change', value, 1)
        }
    }
</script>

<style lang='less' scoped>
  /deep/ .popper .el-cascader-panel .el-checkbox{
    padding: 10px 50px;
  }
</style>
